/*
 * Copyright ©2015-2021 Jaemon. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gitee.jaemon.spring.adorner.util;

import io.gitee.jaemon.spring.adorner.AdornerConstants;
import io.gitee.jaemon.spring.adorner.type.CodeType;

/**
 * markdown工具类
 *
 * @author Jaemon
 * @since 1.0
 */
public class MarkdownUtils {
    public static final String ONE_LEVEL_TITLE_TYPE = "# ";
    public static final String TWO_LEVEL_TITLE_TYPE = "## ";
    public static final String THREE_LEVEL_TITLE_TYPE = "### ";
    public static final String FOUR_LEVEL_TITLE_TYPE = "#### ";
    public static final String FIVE_LEVEL_TITLE_TYPE = "##### ";
    /** 换行符 */
    public static final String LINE_BREAK = AdornerConstants.LINE_BREAK_SYMBOL;
    public static final String TWO_BREAK = "\n\r\n\r";
    public static final String THREE_BREAK = "\n\r\n\r\n\r";
    public static final String FOUR_LINE_BREAK = "\n\r\n\r\n\r\n\r";
    public static final String BRANK_LINE = "&nbsp;";
    public static final String JS_SINGLE_LINE_COMMENTS = "// ";

    private MarkdownUtils() {
    }


    /**
     * json格式代码生成
     *
     * @param content
     *      代码内容
     * @return
     *      代码块
     */
    public static String jsonCode(String content) {
        return code(CodeType.JSON, content);
    }


    /**
     * markdown代码生成
     *
     * @param codeType
     *      代码类型
     * @param content
     *      代码内容
     * @return
     *      代码块
     */
    public static String code(CodeType codeType, String content) {
        String format = "```%s\n%s\n```\n";
        return String.format(format, codeType.type(), content);
    }
}